/*
 * Project: greenline-rms-web-home
 * 
 * File Created at 2013年11月26日
 * 
 * Copyright 2012 Greenline.com Corporation Limited.
 * All rights reserved.
 *
 * This software is the confidential and proprietary information of
 * Greenline Company. ("Confidential Information").  You shall not
 * disclose such Confidential Information and shall use it only in
 * accordance with the terms of the license agreement you entered into
 * with Greenline.com.
 */
package com.greenline.pay.web.home.controllers;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;

import com.greenline.pay.web.common.constants.GlobalConstants;
import com.greenline.pay.web.common.cookie.UserCookieUtil;

/**
 * @Type IndexController
 * @Desc
 * @author Hero_Q
 * @date 2013年11月26日
 * @Version V1.0
 */
@Controller
public class IndexController {
    @Resource
    private HttpServletRequest request;

    /**
     * 首页
     * 
     * @return
     */
    @RequestMapping(value = "/login")
    public String indexDefault(ModelMap model) {
        if (UserCookieUtil.isLogin(request)) {
            return "index";
        }
        return "/login";
    }

    @RequestMapping(value = "/main/main")
    public String main() {
        return "main/main";
    }

    @RequestMapping(value = "/main/index")
    public String index() {
        return "main/index";
    }

    /**
     * 首页
     * 
     * @return
     */
    @RequestMapping(value = "/")
    public String defaultindex() {
        return GlobalConstants.REDIRECT + "/main/main";
    }

    /**
     * 退出
     * 
     * @param model
     * @return
     */
    @RequestMapping("/quit")
    public String quit() {
        UserCookieUtil.clear(request);
        return GlobalConstants.REDIRECT + "/login";
    }

    /**
     * welcome
     * 
     * @return
     */
    @RequestMapping(value = "/welcome")
    public String welcome() {
        return "welcome";
    }

    /**
     * notfound
     * 
     * @return
     */
    @RequestMapping(value = "/notfound")
    public String notFound() {
        return GlobalConstants.NOT_FOUND_VIEW;
    }

    /**
     * error view
     * 
     * @return
     */
    @RequestMapping(value = "/error")
    public String error(ModelMap model) {
        return GlobalConstants.ERROR_VIEW;
    }

    /**
     * expired view
     * 
     * @return
     */
    @RequestMapping(value = "/expired")
    public String expired() {
        return GlobalConstants.EXPIRED_VIEW;
    }
}
